package de.g18.llmaa.gui.lizenzTree;

//Imports
import javax.swing.*;
import javax.swing.tree.*;
import java.awt.*;

public class CustomCellRenderer extends JLabel implements TreeCellRenderer {

	public Component getTreeCellRendererComponent(JTree tree, Object value,
			boolean bSelected, boolean bExpanded, boolean bLeaf, int iRow,
			boolean bHasFocus) {
		// Find out which node we are rendering and get its text
		DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
		String labelText = (String) node.getUserObject();

//		setForeground(Color.LIGHT_GRAY);
		if(bSelected)
		{
//			setBorder(BorderFactory.createLineBorder(Color.ORANGE));
			setForeground(Color.LIGHT_GRAY);
		}else{
//			setBorder(null);
			setForeground(Color.WHITE);
		}
		// Add the text to the cell
		setText(labelText);

		return this;
	}

	// This is a hack to paint the background. Normally a JLabel can
	// paint its own background, but due to an apparent bug or
	// limitation in the TreeCellRenderer, the paint method is
	// required to handle this.
	public void paint(Graphics g) {

		// Set the correct background color

//		g.setColor(new Color(31, 57, 116));

		// Draw a rectangle in the background of the cell
//		g.fillRect(0, 0, getWidth() - 1, getHeight() - 1);

		super.paint(g);
	}

}
